Python/Dictionary Python MCQ set 2 Sample Test,Sample questions

Question:
Anshu created two dictionaries “D1” and “D2” in python. Later on she wants to add all the elements of D2 in D1. As a friend of Anshu, help her to write the code.

1.D1.update(D2)

2.D2.update(D1)

3.D1.append(D2)

4.D2.append(D1)

Posted Date:-2021-12-07 01:28:45


Question:
Dhriti wants to create a dictionary with “Jan”, “Feb”, “Mar” as key and 31, 28, 31 as values respectively. Help her to write the correct code.

1.D = {“Jan” : 31, “Feb” : 28, “Mar” : 31}

2.D = [“Jan”:31, “Feb”:28, “Mar”:31]

3.D = {“Jan” ; 31, “Feb” ; 28, “Mar” ; 31}

4.D = (“Jan”:31, “Feb”:28, “Mar”:31)

Posted Date:-2021-12-07 01:32:43


Question:
Parth wants to display the value corresponding to the key “3” in dictionary given below. As a friend of Parth, help him to find the correct code.D={1: ‘Amit’, 2: ‘Suman’, 3: ‘Ravi’, 4: ‘Anuj’}

1.print(D.get(3))

2.print(D.get(3))

3.Both of the above

4.None of the above

Posted Date:-2021-12-07 01:38:49


Question:
Which operator is used to check if the key is present in the dictionary or not?

1.Mathematical Operator

2.Relational Operator

3.Membership Operator

4.Logical Operator

Posted Date:-2021-12-07 01:35:22


Question:
Write the output of the following :
D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(tuple(D))

1.((1,”Amit”, (2, “Suman”), (3, “Ravi”), (4, “Anuj”))

2.(1, 2, 3, 4)

3.(“Amit”, “Suman”, “Ravi”, “Anuj”)

4.None of the above

Posted Date:-2021-12-07 01:40:08


Question:
Write the output of the following:
D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
m = D.get(2)
print(m[2])

1.. 34

2.45

3.m

4.Suman

Posted Date:-2021-12-07 01:37:28


Question:
Write the output of the following:
D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
print("Amit" in D)

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-07 01:34:30


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!